/**
 * Given a search string and a replace string, this script scans the library
 * for items with a linkage containing the search string, and replaces the found
 * text with the replace string. Finds/Replaces text in both the ClassName and BaseClass fields.
 * 
 * EX:
 * find: "com.wrongpath.utils"
 * replace: "com.rightpath.utils"
 */
var doc=fl.getDocumentDOM();

if(!doc.library)
{
	alert("No document open!");
}
else
{
	scanLibrary(doc.library);
}

function scanLibrary( library )
{
	
	var findStr = prompt( "Text to find" );
	var replaceStr = prompt( "Replace the found text with:" );
	
	var items = library.items;
	var item;
	
	for( var i = 0; i < items.length; i++ )
	{
		item = items[i];
		if( item.linkageExportForAS )
		{
			if( item.linkageBaseClass.length > 0 )
			{
				
				fl.trace(item.linkageBaseClass + " -> " + item.linkageBaseClass.replace(findStr, replaceStr));
				
				item.linkageBaseClass = item.linkageBaseClass.replace(findStr, replaceStr);
			}
			
			if( item.linkageClassName.length > 0 )
			{
				fl.trace(item.linkageClassName + " -> " + item.linkageClassName.replace(findStr, replaceStr));
				
				item.linkageClassName = item.linkageClassName.replace(findStr, replaceStr);
			}
		}
	}
}